import { lazy } from 'react'
import { Navigate } from 'react-router-dom'
import Loading from '@/components/Loading'

// 导入组件模块
const modules = import.meta.glob('/src/pages/**/*.jsx')

function LazyLoad(path) {
  // 懒加载组件
  const Element = lazy(modules[`/src/pages/${path}/index.jsx`])
  return <Loading element={<Element />} />
}

export default [
  { path: '/', element: <Navigate to="index" /> },
  { path: '/index', element: LazyLoad('Layout') },
]
